%%%-------------------------------------------------------------------
%% @doc game top level supervisor.
%% @end
%%%-------------------------------------------------------------------

-module(game_sup).

-behaviour(supervisor).

-export([start_link/0]).

-export([init/1]).

start_link() ->
    {ok, SupPid} = supervisor:start_link({local, ?MODULE}, ?MODULE, []),
    start_all_game_child(SupPid),
    {ok, SupPid}.



%% sup_flags() = #{strategy => strategy(),         % optional
%%                 intensity => non_neg_integer(), % optional
%%                 period => pos_integer()}        % optional
%% child_spec() = #{id => child_id(),       % mandatory
%%                  start => mfargs(),      % mandatory
%%                  restart => restart(),   % optional
%%                  shutdown => shutdown(), % optional
%%                  type => worker(),       % optional
%%                  modules => modules()}   % optional
init([]) ->
    SupFlags = #{strategy => one_for_one,
                 intensity => 20,
                 period => 20},
    ChildSpecs = [],
    {ok, {SupFlags, ChildSpecs}}.

%% internal functions

%% @doc game_sup下面的所有孩子进程启动
start_all_game_child(SupPid) ->
    game_util:simple_start_child(SupPid, role_sup, supervisor),
    game_util:simple_start_child(SupPid, role_mgr_svr),
    ok.
